//
//  DetailViewController.m
//  ElectronicSandTable
//
//  Created by 苏晓凯 on 2017/6/16.
//  Copyright © 2017年 苏晓凯. All rights reserved.
//

#import "DetailViewController.h"
#import "ModelListViewController.h"
#import "AppDelegate.h"
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
@interface DetailViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *modelImageView;
@property (weak, nonatomic) IBOutlet UILabel *labelIntroduction;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self.labelIntroduction setFrame:CGRectMake(10, self.modelImageView.frame.origin.y+self.modelImageView.frame.size.height+10, ScreenWidth-20, 70)];
    self.labelIntroduction.text = @"太行山高速公路邯郸段位于河北省西部邯郸市境内，地处太行山南端，晋冀鲁豫四省交界处，北接太行山高速邢台段，南与河南省林州（豫冀省界）至桐柏高速公路林州段相接，路线经北山底、南山底、在顿井西跨北洺河、集乐东、贺赵西、土岭西、南从井东、在什里店西跨邯长铁路、经琅矿、岭底、经涉县西坡、古台水库西侧、郝赵村东、关防乡西、西达镇东等地，止于合滩乡邰家口村东的漳河翼豫界。路线起点K1＋160.773，止点K69＋846.18，全长68.685km；武安连接线：K0＋000～K9＋386，全长9.386km；王金庄连接线：K0+000～K14+086，连接线全长14.086km。路线设特大桥2座3259.5m．大桥38座15479.5m（其中互通区主线大桥377m/2座），中桥1座97m．小桥19座134m（其中互通区主线小桥30m/3座），涵洞91道（其中互通区主线涵洞12道）；特长隧道1座3122m、中隧道2座1742m，短隧道3座1048.5m；互通式立交6处，分离式立交1处，通道26道，天桥3座，渡槽3座，主线收费站1处，服务区2处，停车区1处，养护工区2处，监控通信分中心1处。太行山高速是带动太行山区脱贫致富；便捷山区群众交通出行；开发太行山区绿色、红色、生态旅游资源，促进假日旅游；促进邯郸西部山区、武安市、涉县整体经济发展。即“扶贫路、旅游路、绿色路”。太行山高速公路邯郸段：工期27.5个月，计划2016年9月开工建设，直到2018年12月30日建成通车。";
    CGSize size = [self sizeWithFont:[UIFont systemFontOfSize:15] maxSize:CGSizeMake(ScreenWidth-20, 3000) labelStr:self.labelIntroduction.text];
    NSLog(@"size.height = %f",size.height);
    CGRect rect = self.labelIntroduction.frame;
    rect.size = size;
    self.labelIntroduction.frame = rect;
    

    self.scrollView.contentSize = CGSizeMake(ScreenWidth, self.labelIntroduction.frame.origin.y + self.labelIntroduction.frame.size.height + 10);
 
    // Do any additional setup after loading the view from its nib.
}

- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize labelStr:(NSString *)labelStr
{
    NSDictionary *attrs = @{NSFontAttributeName : font};
    return [labelStr boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)backAction:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

//查看模型
- (IBAction)checkModelAction:(id)sender {
    ModelListViewController *listVc = [[ModelListViewController alloc]init];
    [self.navigationController pushViewController:listVc animated:YES];
}
//
//-(void)viewWillAppear:(BOOL)animated{
//    [super viewWillAppear:animated];
//    AppDelegate * delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
//    delegate.allowRotate = 0;
//}
//-(void)viewWillDisappear:(BOOL)animated{
//    [super viewWillDisappear:animated];
//    
//}

@end
